<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="file" id="f1" />
    <button id="btn">upload</button>
</body>
<script>
    let f1 = document.getElementById("f1");
    let btn = document.getElementById("btn");
    btn.onclick = function () {
        if (f1.files.length > 0) {
            let fileObj = f1.files[0];
            let formData = new FormData();
            formData.append("image", fileObj);
            formData.append("username", "zhangsan");
            formData.append("age", 20);

            fetch("http://localhost:3000/upload", {
                method: "POST",
                body: formData
            }).then(res => res.json())
                .then(res => {
                    console.log(res)
                })
        }

    }
</script>

</html>